﻿namespace jzgl.Windows
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class Append_Info : Form
    {
        private Button btn_Cancel;
        private Button btn_Save;
        private IContainer components;
        private GroupBox groupBox1;
        private string[] it;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label4;
        private Label label5;
        private TextBox txt_Describer;
        private TextBox txt_Name;
        private TextBox txt_Price;
        private TextBox txt_Unit;

        public Append_Info()
        {
            this.components = null;
            this.it = new string[10];
            this.InitializeComponent();
        }

        public Append_Info(string[] s)
        {
            this.components = null;
            this.it = new string[10];
            this.InitializeComponent();
            this.txt_Name.Text = s[0];
            this.txt_Unit.Text = s[1];
            this.txt_Price.Text = s[2];
            this.txt_Describer.Text = s[3];
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            try
            {
                HouseTypeInfo owner = (HouseTypeInfo) base.Owner;
                owner.add_item[0] = "";
                owner.add_item[1] = "";
                owner.add_item[2] = "";
                owner.add_item[3] = "";
                base.Dispose();
            }
            catch (Exception)
            {
            }
        }

        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.txt_Name.Text.Trim().Equals(""))
                {
                    MessageBox.Show("名称不能为空！");
                }
                else if (this.txt_Unit.Text.Trim().Equals(""))
                {
                    MessageBox.Show("单位不能为空！");
                }
                else
                {
                    HouseTypeInfo owner = (HouseTypeInfo) base.Owner;
                    owner.add_item[0] = this.txt_Name.Text.Trim();
                    owner.add_item[1] = this.txt_Unit.Text.Trim();
                    owner.add_item[2] = this.txt_Price.Text.Trim();
                    owner.add_item[3] = this.txt_Describer.Text.Trim();
                    base.Dispose();
                }
            }
            catch (Exception)
            {
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.groupBox1 = new GroupBox();
            this.label5 = new Label();
            this.txt_Describer = new TextBox();
            this.txt_Price = new TextBox();
            this.txt_Unit = new TextBox();
            this.txt_Name = new TextBox();
            this.label4 = new Label();
            this.label3 = new Label();
            this.label2 = new Label();
            this.label1 = new Label();
            this.btn_Save = new Button();
            this.btn_Cancel = new Button();
            this.groupBox1.SuspendLayout();
            base.SuspendLayout();
            this.groupBox1.Controls.Add(this.label5);
            this.groupBox1.Controls.Add(this.txt_Describer);
            this.groupBox1.Controls.Add(this.txt_Price);
            this.groupBox1.Controls.Add(this.txt_Unit);
            this.groupBox1.Controls.Add(this.txt_Name);
            this.groupBox1.Controls.Add(this.label4);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Location = new Point(3, 0);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(0x195, 230);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "附加项信息";
            this.label5.AutoSize = true;
            this.label5.Location = new Point(13, 0x76);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0x35, 12);
            this.label5.TabIndex = 8;
            this.label5.Text = "及说明：";
            this.txt_Describer.Location = new Point(0x48, 0x63);
            this.txt_Describer.Multiline = true;
            this.txt_Describer.Name = "txt_Describer";
            this.txt_Describer.Size = new Size(0x138, 0x72);
            this.txt_Describer.TabIndex = 7;
            this.txt_Price.Location = new Point(0xe3, 0x3b);
            this.txt_Price.Name = "txt_Price";
            this.txt_Price.Size = new Size(0x5c, 0x15);
            this.txt_Price.TabIndex = 6;
            this.txt_Price.Text = "0";
            this.txt_Price.TextAlign = HorizontalAlignment.Right;
            this.txt_Price.Leave += new EventHandler(this.txt_Price_Leave);
            this.txt_Price.KeyPress += new KeyPressEventHandler(this.txt_Price_KeyPress);
            this.txt_Unit.Location = new Point(0x48, 0x3b);
            this.txt_Unit.Name = "txt_Unit";
            this.txt_Unit.Size = new Size(0x58, 0x15);
            this.txt_Unit.TabIndex = 5;
            this.txt_Name.Location = new Point(0x48, 0x1b);
            this.txt_Name.Name = "txt_Name";
            this.txt_Name.Size = new Size(0xf7, 0x15);
            this.txt_Name.TabIndex = 4;
            this.label4.AutoSize = true;
            this.label4.Location = new Point(13, 0x66);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x35, 12);
            this.label4.TabIndex = 3;
            this.label4.Text = "工艺做法";
            this.label3.AutoSize = true;
            this.label3.Location = new Point(0xa6, 0x3e);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x41, 12);
            this.label3.TabIndex = 2;
            this.label3.Text = "单    价：";
            this.label2.AutoSize = true;
            this.label2.Location = new Point(13, 0x41);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x41, 12);
            this.label2.TabIndex = 1;
            this.label2.Text = "单    位：";
            this.label1.AutoSize = true;
            this.label1.Location = new Point(13, 30);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x41, 12);
            this.label1.TabIndex = 0;
            this.label1.Text = "项目名称：";
            this.btn_Save.Location = new Point(0x105, 0xf5);
            this.btn_Save.Name = "btn_Save";
            this.btn_Save.Size = new Size(0x3d, 0x17);
            this.btn_Save.TabIndex = 1;
            this.btn_Save.Text = "添加";
            this.btn_Save.UseVisualStyleBackColor = true;
            this.btn_Save.Click += new EventHandler(this.btn_Save_Click);
            this.btn_Cancel.Location = new Point(0x152, 0xf5);
            this.btn_Cancel.Name = "btn_Cancel";
            this.btn_Cancel.Size = new Size(0x3b, 0x17);
            this.btn_Cancel.TabIndex = 2;
            this.btn_Cancel.Text = "取消";
            this.btn_Cancel.UseVisualStyleBackColor = true;
            this.btn_Cancel.Click += new EventHandler(this.btn_Cancel_Click);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x199, 0x110);
            base.ControlBox = false;
            base.Controls.Add(this.btn_Cancel);
            base.Controls.Add(this.btn_Save);
            base.Controls.Add(this.groupBox1);
            base.MaximizeBox = false;
            this.MaximumSize = new Size(0x1a1, 0x132);
            base.MinimizeBox = false;
            this.MinimumSize = new Size(0x1a1, 0x132);
            base.Name = "Append_Info";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "附加项目信息";
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            base.ResumeLayout(false);
        }

        private void txt_Price_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = (e.KeyChar < '0') || (e.KeyChar > '9');
            if ((e.KeyChar == '\b') || (e.KeyChar == '.'))
            {
                e.Handled = false;
            }
            if (e.Handled)
            {
                MessageBox.Show(this, "请检查输入的数据！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void txt_Price_Leave(object sender, EventArgs e)
        {
            if (!this.txt_Price.Text.Trim().Contains("."))
            {
                this.txt_Price.Text = this.txt_Price.Text.Trim() + ".00";
            }
        }
    }
}

